,VERSION = 3.00%_agent.hi, ..\foxpro.hU{,_agent_agent.hPixelsClass1_custom_agentagentcontrol Pointer to the agent object activeagent Name of the active Agent errorstate Determines the state of the control during an error erroroccurred Whether an error has occurred *load Loads an agent character from the specified location (can be file or URL) *show Shows the active agent *hide Hides the active agent. *moveto Moves the default agent or agent passed to the location specificed *play Causes the active agent to play an animation *gestureat Causes the active agent to gesture at a given point *speak Causes the active agent to speak the passed phrase *moveby Moves the active agent by the passed values in the x or y direction *localtoworld Converts local coordinates to world coordinates *stop Stops a looping animation *setactiveagent Sets the active agent to the agent with the passed name *interrupt Interrupts an animation *wait Waits for a request to complete  <%aUU %%Cthis.agentControlbOF%Cthis.agentControl.characters("")bOC TLOADC% 8stateShowing, Speaking T-B-U TCAGENTNAMETCAGENTLOCATIONTHIS ERRORSTATE AGENTCONTROL CHARACTERSLOAD ERROROCCURREDGETw%CtnCoordsbN< T%TCTC%CtnCoordsbNT$%Cthis.activeAgentbOa%CN T%CN5T C C pB-U TNXTNYTNCOORDSTOOBJTHIS LOCALTOWORLD DEFAULTCOORDS ACTIVEAGENTLEFTTOPMOVETOSHOWJ$%Cthis.activeAgentbO4CCB-UTHIS ACTIVEAGENTHIDE%CtnCoordsbN< T%TCTC$%Cthis.activeAgentbOCB-UTNXTNYTNCOORDSTOOBJTHIS LOCALTOWORLD ACTIVEAGENTMOVETO$%Cthis.activeAgentbOfCstateTCy T- BU TCANIMATIONLLRETVALTHIS ACTIVEAGENTGETPLAY%CtnCoordsbN< T%TCTC$%Cthis.activeAgentbOCB-UTNXTNYTNCOORDSTOOBJTHIS LOCALTOWORLD ACTIVEAGENT GESTUREATm$%Cthis.activeAgentbOJTC] T- BUTCTEXTLLRETVALTHIS ACTIVEAGENTSPEAK%CtnCoordsbN< T$%Cthis.activeAgentbO'CB-U TNXTNYTNCOORDSTOOBJTHISMOVETO ACTIVEAGENTLEFTTOP &TC LeftTop6 T +C loObj.ClassbC%CloObj.bN!tnPos = tnPos + loObj.&lcAxis 3%C loObj.ClassbCCfFORM %$tnPos = tnPos + _Screen.&lcAxis. )%C loObj.TabsbL %mTT %C loObj.ParentbUT  T- BU TNAXISTNPOSTOOBJLCAXISLOOBJCLASS SHOWWINDOWTABS BORDERWIDTHPARENTJ$%Cthis.activeAgentbO4CCB-UTHIS ACTIVEAGENTSTOP%%Cthis.agentControlbO<%Cthis.agentControl.characters("")bOTCC Ta BU TCAGENTNAMELLRETVALTHIS ACTIVEAGENT AGENTCONTROL CHARACTERSACTIVATEU$%Cthis.activeAgentbO?CNB-U TOREQUESTTHIS ACTIVEAGENT INTERRUPTm$%Cthis.activeAgentbOJTC] T- BU TOREQUESTLLRETVALTHIS ACTIVEAGENTWAIT?"TCAgent.Control.2NTa BCUTHIS AGENTCONTROL CONNECTEDb HF LOADFTaBCUNERRORCMETHODNLINETHIS ERRORSTATE ERROROCCURREDload,showhidemovetoplay gestureatspeakmoveby localtoworldstop setactiveagent4 interrupt? wait Init` Error 1ScBqAAA41AAABQ1AR1AqA4AqA41AABqA2qrBA21AABqA2qrBA21AHqqA3cA5AAAAAAAA2AqA2qrSAA2qBAqA4qrBA2"2AAR1,Gu'8-NA;iESEeaSr s\ Z f} kx3>)IPROCEDURE load LParameters tcAgentName, tcAgentLocation *-- Make sure it inited ok If Type("this.agentControl") = "O" *-- Only load a character once If Type('this.agentControl.characters("' + tcAgentName + '")' ) <> "O" And ; !Empty(tcAgentLocation) this.errorState = "LOAD" this.agentControl.characters.load(tcAgentName, tcAgentLocation) If !this.errorOccurred this.agentControl.characters(tcAgentName).get("state", "Showing, Speaking") Else this.errorOccurred = .F. Return .F. Endif Endif Endif ENDPROC PROCEDURE show LParameters tnX, tnY, tnCoords, toObj If Type("tnCoords") <> "N" tnCoords = COORDS_WORLD Endif If tnCoords = COORDS_LOCAL tnX = this.localToWorld(AXIS_X, tnX, toObj) tnY = this.localToWorld(AXIS_Y, tnY, toObj) Endif If Type("tnCoords") <> "N" tnCoords = this.defaultCoords Endif If Type("this.activeAgent") = "O" If Vartype(tnX) <> "N" tnX = this.activeAgent.Left Endif If Vartype(tnY) <> "N" tnY = this.activeAgent.Top Endif this.activeAgent.moveTo(tnX, tnY) this.activeAgent.show() Else Return .F. Endif ENDPROC PROCEDURE hide If Type("this.activeAgent") = "O" this.activeAgent.hide() Else Return .F. Endif ENDPROC PROCEDURE moveto LParameters tnX, tnY, tnCoords, toObj If Type("tnCoords") <> "N" tnCoords = COORDS_WORLD Endif If tnCoords = COORDS_LOCAL tnX = this.localToWorld(AXIS_X, tnX, toObj) tnY = this.localToWorld(AXIS_Y, tnY, toObj) Endif If Type("this.activeAgent") = "O" this.activeAgent.moveTo(tnX, tnY) Else Return .F. Endif ENDPROC PROCEDURE play LParameters tcAnimation Local llRetVal If Type("this.activeAgent") = "O" this.activeAgent.get("state", tcAnimation) llRetVal = this.activeAgent.play(tcAnimation) Else llRetVal = .F. Endif Return llRetVal ENDPROC PROCEDURE gestureat LParameters tnX, tnY, tnCoords, toObj If Type("tnCoords") <> "N" tnCoords = COORDS_WORLD Endif If tnCoords = COORDS_LOCAL tnX = this.localToWorld(AXIS_X, tnX, toObj) tnY = this.localToWorld(AXIS_Y, tnY, toObj) Endif If Type("this.activeAgent") = "O" this.activeAgent.gestureAt(tnX, tnY) Else Return .F. Endif ENDPROC PROCEDURE speak LParameters tcText Local llRetVal If Type("this.activeAgent") = "O" llRetVal = this.activeAgent.Speak(tcText) Else llRetVal = .F. Endif Return llRetVal ENDPROC PROCEDURE moveby LParameters tnX, tnY, tnCoords, toObj If Type("tnCoords") <> "N" tnCoords = COORDS_WORLD Endif *-- Don't need to convert because we're only moving the relative position *!* If tnCoords = COORDS_LOCAL *!* tnX = this.localToWorld(AXIS_X, tnX, toObj) *!* tnY = this.localToWorld(AXIS_Y, tnY, toObj) *!* Endif If Type("this.activeAgent") = "O" this.moveTo( this.activeAgent.left + tnX, this.activeAgent.top + tnY ) Else Return .F. Endif ENDPROC PROCEDURE localtoworld LParameters tnAxis, tnPos, toObj LOCAL lcAxis, loObj *-- Select the Axis we are converting lcAxis = Iif(tnAxis = 0, "Left", "Top") *-- Calculate offset of all parent containers loObj = toObj Do While Type("loObj.Class") = "C" *-- Pages in PageFrames don't have Left or Top If Type("loObj." + lcAxis) = "N" tnPos = tnPos + loObj.&lcAxis Endif *-- If loObj is a form, we should determine if it's a top level *-- form. If so, we've already calculated the world offset. If not *-- we need the screen offset. If Type("loObj.Class") = "C" And Upper(loObj.Class) = "FORM" If loObj.ShowWindow <> 2 && Top-Level Form tnPos = tnPos + _Screen.&lcAxis. EndIf Endif If Type("loObj.Tabs") = "L" And tnAxis = 1 If loObj.Tabs tnPos = tnPos + 28 && This may be a sysmetric call Else tnPos = tnPos + loObj.BorderWidth * 2 Endif Endif If Type("loObj.Parent") <> "U" loObj = loObj.Parent Else loObj = .F. Endif EndDo Return tnPos ENDPROC PROCEDURE stop If Type("this.activeAgent") = "O" this.activeAgent.stop() Else Return .f. Endif ENDPROC PROCEDURE setactiveagent LParameters tcAgentName Local llRetVal *-- Make sure it inited ok If Type("this.agentControl") = "O" *-- Test to make sure this is a valid character If Type('this.agentControl.characters("' + tcAgentName + '")' ) = "O" this.activeAgent = this.agentControl.characters(tcAgentName) this.activeAgent.Activate() llRetVal = .T. EndIf Endif Return llRetVal ENDPROC PROCEDURE interrupt LParameters toRequest If Type("this.activeAgent") = "O" this.activeAgent.interrupt(toRequest) Else Return .F. Endif ENDPROC PROCEDURE wait LParameters toRequest Local llRetVal If Type("this.activeAgent") = "O" llRetVal = this.activeAgent.wait(toRequest) Else llRetVal = .F. Endif Return llRetVal ENDPROC PROCEDURE Init *-- Create the Agent control this.agentControl = CreateObject("Agent.Control.2") this.agentControl.connected = .T. RETURN DoDefault() ENDPROC PROCEDURE Error LParameters nError, cMethod, nLine Do Case Case this.errorState == "LOAD" this.errorOccurred = .T. RETURN EndCase DoDefault(nError, cMethod, nLine) ENDPROC =Height = 42 Width = 42 errorstate = LOAD Name = "_agent" custom _base.vcx